package com.shuoyue.ycgk.entity;

import android.text.TextUtils;

import com.shuoyue.ycgk.ui.questionbank.practice.specialtraining.EpInfo;
import com.shuoyue.ycgk.views.PaintView;

import java.io.Serializable;
import java.lang.ref.SoftReference;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import lombok.Data;

@Data
public class QuestionSimple implements Serializable {
    int id;
    int questionId;//跟ID一样的,做题的时候返回到这个地方了,查询题目又返回到id上了

    int memberPaperDetailId;
    /**
     * 标题
     */
    String stem;


    /**
     * 解析
     */
    String analysis;

    /**
     * 选项
     */
    ArrayList<Option> questionSimpleOptionDTOS;
    /**
     * 选项(搜索里面key不一样)
     */
    ArrayList<Option> questionOptions;

    /**
     * 题目类型 1:单选,2多选,3判断
     */
    int questionType;
    /**
     * 是否显示正确答案
     */
    boolean isShowRight;
    /**
     * 答题用时
     */
    long useTime = 0;
    /**
     * 我的答案
     */
    ArrayList<String> myChooseAnswer;

    ArrayList<String> imgs;

    float score;

    /**
     * 父元素编号,-1表示普通题目
     */
    int parentPos = -1;

    /**
     * 用户是否答对此题 1;正确,0错误;2未作答;3已做答,未核对
     */
    int isAnswerRight = 2;

    String answer;//用户答案,来自网络
    /**
     * 显示编号
     */
    int num;

    int isCollect;
    int materialQuestionId;
    String rightKey;

    int textsize = 17;
    ArrayList<EpInfo> examinationPointDTOS;

    SoftReference<ArrayList<PaintView.DrawPath>> notePathReference;

    public void changeSoftNotePath(List<PaintView.DrawPath> drawPaths) {
        if (notePathReference == null) {
            ArrayList<PaintView.DrawPath> notePath = new ArrayList<>();
            notePathReference = new SoftReference(notePath);
        } else {
            ArrayList<PaintView.DrawPath> notePath = notePathReference.get();// new ArrayList<>();
            if (notePath == null) {
                notePath = new ArrayList<>();
            }
        }
        try {
            notePathReference.get().clear();
            notePathReference.get().addAll(drawPaths);
        } catch (Exception e) {

        }

    }

    public ArrayList<PaintView.DrawPath> getSoftNotePath() {
        if (notePathReference != null && notePathReference.get() != null) {
            return notePathReference.get();
        }
        return new ArrayList<>();
    }

//    public void setAnswer(String answer) {
//        this.answer = answer;
//        if (!TextUtils.isEmpty(answer)) {
//            String[] as = answer.split(",");
//            this.myChooseAnswer = (ArrayList<String>) Arrays.asList(as);
//        }
//    }
}
